import { getuserName, setuserName, removeuserName } from '@/utils/storage'

export default {
  namespaced: true, // 打开命名空间
  state: () => ({

    userInfo: getuserName() // 获取用户名

  }),

  mutations: {

    setUsernameInfo (state, obj) {
      state.userInfo = obj
      setuserName(obj)
    },
    clearUserInfo (state) {
      // state.userInfo = null
      removeuserName() // 调用删除方法
    }

  },
  actions: {

  },
  getters: {
    username: state => state.userInfo // 通过getter暴露数据

  }

}
